#include "coordinate.h"
void Coordinate::loadAttributes(std::istream &inData)
{
  inData >> x >> y >> z;
  inData.ignore();
}
void Coordinate::normalize()
{
  double l = magnitude();
  x /= l;
  y /= l;
  z /= l;
}
double Coordinate::dot() const 
{ 
  return x * x + y * y + z * z; 
}
double Coordinate::dot(const Coordinate &b) const 
{ 
  return x * b.x + y * b.y + z * b.z; 
}
double Coordinate::distance(const Coordinate &b) const 
{
  return (b - *this).magnitude();
}
double Coordinate::magnitude() const
{
  return std::sqrt(dot());
}
const Coordinate Coordinate::operator*(const double &n) const
{
  Coordinate c;
  c.x = x * n;
  c.y = y * n;
  c.z = z * n;

  return c;
}
const Coordinate Coordinate::operator+(const Coordinate &b) const
{
  Coordinate c;
  c.x = x + b.x;
  c.y = y + b.y;
  c.z = z + b.z;

  return c;
}
const Coordinate Coordinate::operator-(const Coordinate &b) const
{
  Coordinate c;
  c.x = x - b.x;
  c.y = y - b.y;
  c.z = z - b.z;

  return c;
}
